<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="div1" align="center">
			<select id="selectd" onchange="szi()">
				<option value="xz">请选择大小 </option>
				<option value="b">大 </option>
				<option value="s">小 </option>
			</select>
			<div id="div2">
				<img src="img2/1.jpg" value="1" id="img" width="110px" height="110px"  />
			</div>
		</div>
		
	</body>
	<script type="text/javascript">
		function szi(){
			var de=document.getElementById('selectd').value;
			var zhi=document.getElementById('img');
			 var s = zhi.getAttribute("value");
			
			if(de=='b'){
					 show();
				if(s=='4' || s=='5' || s=='6'){
					alert('你猜对了');
				}else{
					alert('你猜错了');
				}
			}
				
			if(de=='s'){
				 show();
				if(s=='3'|| s=='2' || s=='1'){
					alert('你猜对了');
				}else{
					alert('你猜错了');
				}
			}
			
		}
		// setTimeout(function(){
		// 	var randNum  = getRandValidNum();
		// 	var next = document.getElementById("img");
		// 	next.src = "img2/"+randNum+".jpg";
		// 	 var zhi=document.getElementById('img');
		// 	 zhi.vaule='randNum';
		// },5000);
		
		function show(){
			setTimeout(function(){
				var randNum  = getRandValidNum();
				var next = document.getElementById("img");
				next.src = "img2/"+randNum+".jpg";
				 var zhi=document.getElementById('img');
				 zhi.vaule='randNum';
			},1000);
		}
		function getRandValidNum(){
			while(true){
				var randNum = Math.floor(Math.random()*7);
				if(randNum!=0){
					return randNum;
				}
			}				
		}
	</script>
</html>
